package cn.trs.common.enums;

/**
 * 智能体访问模式
 */
public enum AccessModeEnum {
    /**
     * 正常模式
     */
    NORMAL(1, "normal"),
    /**
     * 预览模式
     */
    PREVIEW(2, "preview"),
    ;

    AccessModeEnum(Integer code, String mode) {
        this.code = code;
        this.mode = mode;
    }

    public Integer getCode() {
        return code;
    }

    public String getMode() {
        return mode;
    }

    private final Integer code;
    private final String mode;

    public static Integer getCodeByMode(String mode){
        for (AccessModeEnum accessModeEnum: AccessModeEnum.values()) {
            if (mode.equals(accessModeEnum.getMode())) {
                return accessModeEnum.getCode();
            }
        }
        return null;
    }

    public static AccessModeEnum getByMode(String mode){
        for (AccessModeEnum accessModeEnum: AccessModeEnum.values()) {
            if (mode.equals(accessModeEnum.getMode())) {
                return accessModeEnum;
            }
        }
        return null;
    }
}
